package bearworker.zxl.dao.mapper.extra;

import bearworker.zxl.entity.ManagerMenu;
import bearworker.zxl.entity.extra.PrivMenuEntEntity;
import bearworker.zxl.entity.extra.UserMenuEntity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

/**
 * Created by 逍遥的熊 on 2018/1/18.
 */

public interface SystemMapper {

    @SelectProvider(type = SystemSqlProvider.class,method = "getUserPriv")
    @Results({
        @Result(column = "user_id",property = "userId",jdbcType = JdbcType.INTEGER),
        @Result(column = "menu_id",property = "menuId",jdbcType = JdbcType.INTEGER),
        @Result(column = "menu_name",property = "menuName",jdbcType = JdbcType.VARCHAR),
        @Result(column = "url",property = "url",jdbcType = JdbcType.VARCHAR),
        @Result(column = "method",property = "method",jdbcType = JdbcType.VARCHAR),
        @Result(column = "parent_id",property = "parentId",jdbcType = JdbcType.INTEGER),
        @Result(column = "menu_key",property = "menuKey",jdbcType = JdbcType.VARCHAR),
        @Result(column = "is_display",property = "isDisplay",jdbcType = JdbcType.INTEGER),
        @Result(column = "sort",property = "sort",jdbcType = JdbcType.INTEGER)
    })
    List<UserMenuEntity> getUserPriv(@Param("parentId") Integer paraentId,@Param("userId") Integer userId);

    @SelectProvider(type = SystemSqlProvider.class,method = "getPriviDetail")
    @Results({
            @Result(column = "id",property = "id",jdbcType = JdbcType.INTEGER),
            @Result(column = "mName",property = "mName",jdbcType = JdbcType.VARCHAR),
            @Result(column = "mKey",property = "mKey",jdbcType = JdbcType.VARCHAR),
            @Result(column = "state",property = "state",jdbcType = JdbcType.INTEGER),
    })
    List<PrivMenuEntEntity> getPriviDetail(@Param("id") Integer id);

    @SelectProvider(type = SystemSqlProvider.class,method = "getPriviDetail2")
    @Results({
            @Result(column = "id",property = "id",jdbcType = JdbcType.INTEGER),
            @Result(column = "mName",property = "mName",jdbcType = JdbcType.VARCHAR),
            @Result(column = "mKey",property = "mKey",jdbcType = JdbcType.VARCHAR),
            @Result(column = "state",property = "state",jdbcType = JdbcType.INTEGER),
    })
    List<PrivMenuEntEntity> getPriviDetail2(@Param("id") Integer id);

    @SelectProvider(type = SystemSqlProvider.class,method = "getPmenus")
    @Results({
            @Result(column = "id",property = "id",jdbcType = JdbcType.INTEGER),
            @Result(column = "menu_name",property = "menuName",jdbcType = JdbcType.VARCHAR)
    })
    List<ManagerMenu> getPmenus(@Param("priviId") Integer priviId);

    @SelectProvider(type = SystemSqlProvider.class,method = "getSmenus")
    @Results({
            @Result(column = "id",property = "id",jdbcType = JdbcType.INTEGER),
            @Result(column = "menu_name",property = "menuName",jdbcType = JdbcType.VARCHAR)
    })
    List<ManagerMenu> getSmenus(@Param("priviId") Integer priviId);

}
